#ifndef LAND_H
#define LAND_H

#include <QtWidgets>
#include "landblock.h"
#include "pos.h"

namespace Ui {
class Land;
}

class Land : public QWidget
{
    Q_OBJECT

public:
    explicit Land(QWidget *parent = nullptr);
    ~Land();

public:
    void initialize();
    void initLand();
    void initLandMines();
    QList<LandBlock *> findNearbyBlocks(Pos &pos);
    QList<LandBlock *> findNearbyBlocks(LandBlock *block);
    int scan(int idx);
    int scan(Pos &pos);
    void scanLandMines();
    Pos *indexToPos(int idx);
    int posToIndex(int row, int column); // (0, 1, ..., N-1) 行/列
    int posToIndex(Pos *pos);

public slots:
    void autoDetect();

private:
    Ui::Land *ui;
    QGridLayout *gridLayout;
    int row_num = 9, column_num = 9;
    int landMineMax = 10;
    QList<LandBlock *> blocks;
    int landMinesMap[1000];
};

#endif // LAND_H
